"""
xapper app settings.

This file contains all the default settings for the xapper app.  All code in
the xapper app should use xapper.conf.settings rather than
django.conf.settings to pick up these default values.
"""

import copy
import django.conf


default_settings = {
  # The list of assemblies included if no assemblies are specified for a
  # particular .app.  The default is the set of assemblies required to run an
  # IronPython script via Microsoft.Scripting.Silverlight.
  "XAPPER_DEFAULT_ASSEMBLIES": (
    "Microsoft.Scripting.Silverlight.dll",
    "Microsoft.Scripting.ExtensionAttribute.dll",
    "Microsoft.Scripting.Core.dll",
    "Microsoft.Scripting.dll",
    "IronPython.dll",
    "IronPython.Modules.dll",
  ),

  # The assembly in which to search for the entry-point type if no
  # entry-point assembly is specified for a particular app.
  "XAPPER_DEFAULT_ENTRY_POINT_ASSEMBLY": "Microsoft.Scripting.Silverlight",

  # The type used as the entry point for the app if none is specified for a
  # particular app.
  "XAPPER_DEFAULT_ENTRY_POINT_TYPE": "Microsoft.Scripting.Silverlight.DynamicApplication",

  # The finders used to search for silverlight app directories when
  # constructing a .xap file.
  "XAPPER_SILVERLIGHT_APP_FINDERS": (
    "xapper.finders.filesystem_app_finder",
    "xapper.finders.app_directories_app_finder",
  ),

  # The finders used to search for assemblies when constructing a .xap file.
  "XAPPER_ASSEMBLY_FINDERS": (
    "xapper.finders.filesystem_assembly_finder",
    "xapper.finders.app_directories_assembly_finder",
  ),

  # The directories searched when looking for Silverlight libraries.
  "XAPPER_SILVERLIGHT_APP_DIRS": (),

  # The directories searched when looking for assemblies.
  "XAPPER_ASSEMBLY_DIRS": (),

  # The directory for static .xap files.
  "XAPPER_STATIC_XAP_DIR": None,
}


required_settings = (
)


class ConfigurationError(Exception): pass


settings = copy.copy(django.conf.settings)
for key, value in default_settings.iteritems():
  if not hasattr(settings, key):
    setattr(settings, key, value)
    for key in required_settings:
      if not hasattr(settings, key):
        raise ConfigurationError("Missing required xapper configuration setting: %s" % key)
